<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>js数据类型</title>
</head>
<body>
    
</body>
<script>
    //基本数据类型
    //number
    //string
    //boolean
    //null
    //undefined
    alert(typeof 3.14)
    alert(typeof 5)

    alert(typeof "5")
    alert(typeof "nishi")

    alert(typeof true)
    alert(typeof false)

    alert(typeof null) //显示object代表是一个对象
    
    alert(typeof undefined)

    //引用数据类型

    //运算符与java一致
    //比较 == 与 ===
    
    // ==对比先进行类型转换
    console.log(3 == '3')

    // === 不进行类型转换
    console.log(3 === '3')

    //js中的类型转换
    //字符串转整数
    console.log(parseInt("123"))
    console.log(parseInt("38f88"))
    console.log(parseInt("f123")) //NaN

    //转为bool类型
    //下述5种情况为false，其他均为true
    if(0){
        console.log("success") //NaN
    }
    if(NaN){
        console.log("success") //NaN
    }
    if(null){
        console.log("success") //NaN
    }
    if(""){
        console.log("success") //NaN
    }
    if(undefined){
        console.log("success") //NaN
    }

</script>
</html>